import mysql from 'mysql'
import conf from '../conf.js'

export default (sql, callback) => {
  const { dbHost, dbPort } = conf
  const conn = mysql.createConnection({
    host: dbHost,
    port: dbPort,
    // user、password需手动添加,与数据库保持一致
    user: '',
    password: '',
    database: 'mysqlDB',
  })
  // 建立连接
  conn.connect()
  conn.query(sql, callback)
  // 断开连接
  conn.end()
}
